﻿#region LGPL Header
/* This file is part of ErrorProviders.

    ErrorProviders is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    ErrorProviders is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with ErrorProviders; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  
*/
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DemoApp
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();

            //There is an exemple for setting validate method to all child of GridErrorProvider and an other to a particular child
            this.errorProvider.ValidateMethod = new ErrorProviders.ValidateDataCallback(ValidateMethodCollection.GenericValidateMethod);
            ErrorProviders.StackPanelErrorProvider.SetValidateMethod(this.passwordBox, new ErrorProviders.ValidateDataCallback(ValidateMethodCollection.PasswordValidateMethod));
            
            //There is an exemple for setting a custom objet as an error value
            ErrorProviders.StackPanelErrorProvider.SetErrorValue(this.textboxUserName, App.Current.Resources["TextBoxError"]);
        }

        

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.errorProvider.ValidateContent();
        }

    }
}
